﻿namespace Sai.Core.Reporting
{
    using System;
    using System.Collections.Generic;

    public class ReportTransformationRegistry
    {
        private List<IReportTransformationRepository> repositories = new List<IReportTransformationRepository>();

        public void Add(IReportTransformationRepository repo)
        {
            this.repositories.Add(repo);
        }

        public IReportTransformation Find(Type objectType, ReportFormat format)
        {
            foreach (var repo in this.repositories)
            {
                IReportTransformation candidate = repo.Find(objectType, format);

                if (candidate != null)
                {
                    return candidate;
                }
            }

            return null;
        }
    }
}
